Skip to content

Add "Open in VS Code Diff" button to plan diff viewer#180

Merged
backnotprop merged 10 commits intomainfrom
claude/vscode-diff-viewer-button-sv38a
Feb 26, 2026
Merged

Add "Open in VS Code Diff" button to plan diff viewer#180
backnotprop merged 10 commits intomainfrom
claude/vscode-diff-viewer-button-sv38a

Conversation

@backnotprop
Copy link
Owner

Summary

Add a new "VS Code" button to the PlanDiffViewer toolbar that opens the current plan diff in VS Code's native side-by-side diff viewer. This gives power users access to VS Code's mature diff features like inline editing, word-level highlighting, and search.

Changes

  • Server endpoint (packages/server/index.ts): Add POST /api/plan/vscode-diff that writes both plan versions to temp files and spawns code --diff <old> <new>. Includes graceful error handling for when the VS Code CLI is not installed.

  • UI button (packages/ui/components/plan-diff/PlanDiffViewer.tsx):

    • Add "VS Code" button in the diff mode switcher row with VS Code icon
    • Add three new props: currentPlan, basePlan, and baseVersion
    • Implement loading state and error display with dismissible error message
    • Button is only shown when all required data is available
  • Wire up props (packages/editor/App.tsx): Pass the three new props from the parent component to PlanDiffViewer

Implementation Details

  • Uses Bun.spawn() to invoke the VS Code CLI—no new dependencies required
  • Temp files are written to the existing /tmp/plannotator/ directory, following the pattern already used for image uploads
  • Files are overwritten on each click (no accumulation)
  • Error message provides helpful guidance if VS Code CLI is not found
  • Button text is hidden on mobile (icon-only), visible on desktop

https://claude.ai/code/session_01FYcJkGsWfuiGy53x3pwCSW

claude and others added 10 commits February 25, 2026 01:00
Scoping document for a new PlanDiffViewer button that opens
the plan diff in VS Code's native diff viewer via `code --diff`.

https://claude.ai/code/session_01FYcJkGsWfuiGy53x3pwCSW
Add a button in the PlanDiffViewer toolbar that opens the current
plan diff in VS Code's native side-by-side diff viewer. The server
writes both versions to temp files and spawns `code --diff`.

- New POST /api/plan/vscode-diff endpoint in packages/server/index.ts
- VS Code button with loading/error states in PlanDiffViewer.tsx
- Wire currentPlan/basePlan/baseVersion props from App.tsx

https://claude.ai/code/session_01FYcJkGsWfuiGy53x3pwCSW
…om client

The server already has the current plan in its closure and can read
any version from disk via getPlanVersion(). No need to send plan
text from the UI — just send baseVersion.

https://claude.ai/code/session_01FYcJkGsWfuiGy53x3pwCSW
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… writing temp files

Both plan versions already exist on disk in ~/.plannotator/history/.
Eliminates redundant file writes, fixes UPLOAD_DIR semantic misuse,
and corrects HTTP status codes for editor errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tor UI

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@backnotprop backnotprop merged commit 7145f19 into main Feb 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants